package com.firexxx.study.designmodel.proxy;

/**
 * @description: TODO
 * @throws:
 * @author: zhuangzhang2
 * @date: 2019/11/13 14:30
 */
public class Proxy implements Subject {

    private RealSubject realSubject = null;

    public Proxy(RealSubject realSubject) {
        this.realSubject = realSubject;
    }

    private void beforeExecute() {
        System.out.println("i am before");
    }

    @Override
    public void execute() {
        beforeExecute();
        realSubject.execute();
        afterExecute();
    }

    private void afterExecute() {
        System.out.println("i am after");
    }
}